// set path 
gl path "~/"

use id year birth_year g_ homeowner_g reg_year using "$path/Replication/ohio_analysis_local.dta" if birth_year >= 1945 & birth_year <= 1980, clear

// keep if registered before treatment
keep if reg_year < year

// run regression subsetting to each birth year
matrix B=J(36,3,.)
forvalues j=1945/1980 {
	di `j'
	reghdfe g_ homeowner_g if birth_year==`j', a(id year) cluster(id)
	matrix B[`j'-1944, 1] = _b[homeowner_g]
	matrix B[`j'-1944, 2] = _se[homeowner_g]
	matrix B[`j'-1944, 3] = `j'
}

// save matrix 
svmat B
// generate lower and upper bounds
gen lb = B1 - (B2 *1.96)
gen ub = B1 + (B2 * 1.96)
scatter B1 B3, xtitle("Year of Birth") ///
	ytitle("Effect on Pr(Vote in General)") xlabel(1945(5)1980) ///
	scale(1.3) || rcap lb ub B3, legend(off)

graph export "$path/Replication/figure3.pdf", replace
graph export "$path/Replication/figure3.eps", replace

